#include "Arduino.h"
#include "TrainData.h"

/* CONSTRUCTOR */
TrainData::TrainData(byte id, int potentiometerPort, int pushButtonPort, int ledPort) {
  if(potentiometerPort < TrainData::minPotentiometerPort || potentiometerPort > TrainData::maxPotentiometerPort) {
    m_potentiometerPort = potentiometerPort;
  }
  else
  {
    m_potentiometerPort = potentiometerPort;
  }
  
  if(pushButtonPort < TrainData::minPushButtonPort || pushButtonPort > TrainData::maxPushButtonPort) {
    m_pushButtonPort = 0U;
  }
  else
  {
    m_pushButtonPort = pushButtonPort;
  }
  
  if(ledPort < TrainData::minLedPort || ledPort > TrainData::maxLedPort) {
    m_ledPort = 0U;
  }
  else
  {
    m_ledPort = ledPort;
  }
}
    
/* METHODES */
/**
* \brief Get Train data Id
* \param none
* \return Id
*/ 
byte TrainData::getId() {
  return m_id;
}

/**
* \brief Get Potentiometer port
* \param none
* \return potentiometerPort
*/ 
int TrainData::getPotentiometerPort() {
  return m_potentiometerPort;
}

/**
* \brief Get switch port
* \param none
* \return switchPort
*/ 
int TrainData::getPushButtonPort() {
  return m_pushButtonPort;
}

/**
* \brief Get Train data led port
* \param none
* \return ledPort
*/ 
int TrainData::getLEDPort() {
  return m_ledPort;
}
